import React, { useEffect, useState } from 'react'
import routes from './router/index'
import { BrowserRouter as Router, Switch, Route ,useLocation} from 'react-router-dom'
import { ConfigProvider } from 'zarm'
import zhCN from 'zarm/lib/config-provider/locale/zh_CN'
import NavBar from './components/NavBar'
function App() {

  const location = useLocation()
  const {pathname} = location
  const needNav = ['/', '/data', '/user']
  const [showNav, setShowNav]  = useState(false)
  useEffect(()=>{
    setShowNav(needNav.includes(pathname))
  },[pathname])
  return <Router>
    <ConfigProvider>

      <Switch>
        {
          routes.map(route => <Route exact key={route.path} path={route.path} >
            <route.component></route.component>
          </Route>)
        }
      </Switch>
    </ConfigProvider>
    <NavBar showNav={showNav}></NavBar>

  </Router>
}

export default App
